package com.lrkj.back.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lrkj.back.entity.ZsHuishou;
import com.lrkj.back.entity.ZsHuishouMingxi;
import com.lrkj.back.mapper.ZsHuishouMingxiMapper;
import com.lrkj.back.service.ZsHuishouMingxiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.com.cbons.mamisay.parent.db.api.DBInterface;
import cn.com.cbons.mamisay.parent.exception.DBException;
import cn.com.cbons.mamisay.parent.service.base.ParentServiceImpl;

@Transactional
@Service
public class ZsHuishouMingxiSericeImple extends ParentServiceImpl<ZsHuishouMingxi> implements ZsHuishouMingxiService {
    @Autowired
    private ZsHuishouMingxiMapper huishouMingxi;

    @Override
    public List<ZsHuishouMingxi> findAllHuishouMingxi(Map<String, Object> map,int type) throws DBException {
        List<ZsHuishouMingxi> list= new ArrayList<>();
        if(type==0){
            list  = huishouMingxi.selectByhuishouliushui(map);
        }else if(type==1){
            list = huishouMingxi.selectByhuishouliushui2(map);
        }

        return list;
    }

    @Override
    protected DBInterface<ZsHuishouMingxi> getDao() throws DBException {
        // TODO Auto-generated method stub
        return huishouMingxi;
    }

    @Override
    public int deleteByhsls(String huishouliushui) throws DBException {

        return huishouMingxi.deleteByhsls(huishouliushui);
    }

    @Override
    public int deleteByTiaoma(List<String> packageTiaoma) throws DBException {

        return huishouMingxi.deleteByTiaoma(packageTiaoma);
    }

    @Override
    public List<ZsHuishouMingxi> findHuishouMingxiByWanglan(Map<String, Object> map) throws DBException {

        return huishouMingxi.selectByWanglanTiaoma(map);
    }

    @Override
    public PageInfo<ZsHuishouMingxi> findAllHuishouMingxiPage(Map<String, Object> map,Integer type) throws DBException {
        PageHelper.startPage(Integer.valueOf(map.get("pageNo").toString()),
                Integer.valueOf(map.get("pageSize").toString()));
        type = type==null?0:type;
        List<ZsHuishouMingxi> list= new ArrayList<>();
        if(type==0){
            list  = huishouMingxi.selectByhuishouliushui(map);
        }else if(type==1){
            list = huishouMingxi.selectByhuishouliushui2(map);
        }
        PageInfo<ZsHuishouMingxi> page = new PageInfo<>(list);
        return page;
    }

    @Override
    public List<ZsHuishouMingxi> findAllHuishouMingxi(Map<String,Object> map){
        return huishouMingxi.findAllHuishouMingxi(map);
    }

    @Override
    public List<ZsHuishouMingxi> selectByCost(Map<String, Object> map) throws DBException {
        return huishouMingxi.selectByCost(map);
    }

}
